+2007-04-19 Matthias Clasen <mclasen@redhat.com>
+
+ * gtk/gtkicontheme.h:
+ * gtk/gtkicontheme.c: Add GTK_ICON_LOOKUP_GENERIC_FALLBACK
+ icon lookup flag and implement it. (#396901, Luca Ferreti)
+
2007-04-18 Richard Hult <richard@imendio.com>
* gdk/quartz/gdkwindow-quartz.c:
UnthemedIcon *unthemed_icon;
gboolean allow_svg;
gboolean use_builtin;
+ gboolean generic_fallback;
g_return_val_if_fail (GTK_IS_ICON_THEME (icon_theme), NULL);
g_return_val_if_fail (icon_name != NULL, NULL);
else
allow_svg = priv->pixbuf_supports_svg;
- use_builtin = (flags & GTK_ICON_LOOKUP_USE_BUILTIN);
-
+ use_builtin = flags & GTK_ICON_LOOKUP_USE_BUILTIN;
+ generic_fallback = flags & GTK_ICON_LOOKUP_GENERIC_FALLBACK;
+
ensure_valid_themes (icon_theme);
for (l = priv->themes; l; l = l->next)
{
IconTheme *theme = l->data;
- icon_info = theme_lookup_icon (theme, icon_name, size, allow_svg, use_builtin);
+ gchar *name = g_strdup (icon_name);
+ gchar *s;
+
+ while (TRUE)
+ {
+ icon_info = theme_lookup_icon (theme, name, size, allow_svg, use_builtin);
+ if (icon_info || !generic_fallback)
+ break;
+
+ s = strrchr (name, '-');
+ if (!s)
+ break;
+
+ *s = '\0';
+ }
+
+ g_free (name);
+
if (icon_info)
goto out;
}
* gtk_icon_theme_lookup_icon() includes builtin icons
* as well as files. For a builtin icon, gtk_icon_info_get_filename()
* returns %NULL and you need to call gtk_icon_info_get_builtin_pixbuf().
+ * @GTK_ICON_LOOKUP_GENERIC_FALLBACK: Try to shorten icon name at '-'
+ * characters before looking at inherited themes.
*
* Used to specify options for gtk_icon_theme_lookup_icon()
**/
{
GTK_ICON_LOOKUP_NO_SVG = 1 << 0,
GTK_ICON_LOOKUP_FORCE_SVG = 1 << 1,
- GTK_ICON_LOOKUP_USE_BUILTIN = 1 << 2
+ GTK_ICON_LOOKUP_USE_BUILTIN = 1 << 2,
+ GTK_ICON_LOOKUP_GENERIC_FALLBACK = 1 << 3
} GtkIconLookupFlags;
#define GTK_ICON_THEME_ERROR gtk_icon_theme_error_quark ()